#pragma once

#include "imglib/bitmap.h"
#include "typelib/affine.h"
#include <boost/shared_ptr.hpp>
#include <outline/controls.h>
#include "compressed_mask.h"

namespace trm {

typedef img::bitmap bit_mask;
typedef outline::controls<float> bezier_contour;

struct twomasks;
typedef boost::shared_ptr<twomasks> twomasks_sptr;
typedef boost::shared_ptr<const twomasks> twomasks_const_sptr;

struct twomasks
{
	//visible data
	bit_mask b;
	compressed_grey_mask g;
	//internal data
	bezier_contour contour;
	affine motion; ///< valid only if optic flow motion prediction is computed
	int ref_frame; ///< absolute time (or -1 to indicate absence of motion data)
public:
	twomasks() : ref_frame(-1) { }
	xml::stream & serialize(xml::stream & s);
	twomasks_sptr copy_except_grey() const;
};

//inlines

inline xml::stream & operator || (xml::stream & s, twomasks & t)
	{ return t.serialize(s); }

inline twomasks_sptr twomasks::copy_except_grey() const {
	twomasks_sptr p(new twomasks);
	p->b = b;
	p->contour = contour;
	p->ref_frame = ref_frame;
	if (ref_frame != -1)
		p->motion = motion;
	return p;
}

} //namespace trm
